using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EffectBehaviour : MonoBehaviour
{
    protected ParticleSystem[] particals;
    protected float m_recoverTime;

    public virtual void Play(float delyHide)
    {
        m_recoverTime = Time.time + delyHide;
        if (particals == null)
        {
            particals = gameObject.GetComponentsInChildren<ParticleSystem>();
        }
        if (particals != null)
        {
            foreach (var item in particals)
            {
                item.Play();
            }
        }
        gameObject.SetActive(true);
    }
    public virtual void Update()
    {
        if (Time.time > m_recoverTime)
        {
            EffectAgent.Instance.SaveBackEffect(gameObject);
            gameObject.SetActive(false);
        }
    }
}
